@echo off
:: assuming mysql is in %PATH%
:: this script must be run from its own dir.

set CREATE_DB=create_db.sql
set ROOTPASS=root
set CREATE_DB_TABLES=create_db_tables.sql
set INSERT_TO_DB=insert_to_db.sql
set REPLACE=$$name$$
set TEMP=temp.tmp

call BatchSubstitute.bat %REPLACE% %1 %CREATE_DB% %TEMP%

:: creates the data base and user...
mysql -uroot -p%ROOTPASS% --default-character-set=utf8  < %TEMP%

del %TEMP%

:: creates the tables for the user on its database.
mysql -u%1 -p%1 --default-character-set=latin1 %1 < %CREATE_DB_TABLES%
:: add to the db
mysql -u%1 -p%1 --default-character-set=latin1 %1 < %INSERT_TO_DB%

